package org.finesys.common.log.trace.util;

import org.aopalliance.intercept.MethodInterceptor;
import org.springframework.aop.framework.ProxyFactory;

/**
 * 代理获取工具类
 */
public class ProxyUtil {

    /**
     * proxy
     *
     * @param object            object
     * @param methodInterceptor 拦截器
     * @return 代理
     */
    public static Object getProxy(final Object object, final MethodInterceptor methodInterceptor) {
        ProxyFactory proxyFactory = new ProxyFactory(object);
        proxyFactory.setProxyTargetClass(true);
        proxyFactory.addAdvice(methodInterceptor);
        return proxyFactory.getProxy();
    }
}
